using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region APPartner

	/// <summary>
	/// APPartner object for NHibernate mapped table 'APPartner'.
	/// </summary>
	[Serializable]
	public class APPartner : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected DicItem _partnerType;
		protected ActionPoint _actionPoint;
		protected Employee _employee;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public APPartner() { }

		public APPartner( DicItem partnerType, ActionPoint actionPoint, Employee employee )
		{
			this._partnerType = partnerType;
			this._actionPoint = actionPoint;
			this._employee = employee;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public DicItem PartnerType
		{
			get { return _partnerType; }
			set { _partnerType = value; }
		}

		public ActionPoint ActionPoint
		{
			get { return _actionPoint; }
			set { _actionPoint = value; }
		}

		public Employee Employee
		{
			get { return _employee; }
			set { _employee = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is APPartner))
				throw new InvalidCastException("This object is not of type APPartner");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((APPartner)obj).Id);
					break;
                default:
                    goto case "Id";
			}
            if (APPartner.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
